{{!connect "theme/widget/common.css"}}

<!-- Следует наследовать виджеты главной страницы от этого шаблона -->


<!-- дефолтное тело виджета -->

<div class="widget {{@:widget_class}}{{:widget_class}}{{/:widget_class}} wg-sortable" id="{{widget.widget_id}}"><div class="bg1-"><div class="bg2-">
	{{?widget.moderator_mode}}
		<div class="panel-"><div class="bgg1-">
			{{@:actions}}{{:actions}}
				<ul class="actions-">
					{{?widget.ui_configurable}}
					<li class="edit-"><a href="#"><img src="{{!static type='images' 'icons2/page_white_edit.png'}}" alt="[Р]" title="Редактировать раздел" /></a></li>
					{{/?}}
					<li class="delete-"><a href="#"><img src="{{!static type='images' 'icons2/page_white_delete.png'}}" alt="[У]" title="Удалить раздел" /></a></li>
				</ul>
			{{/:actions}}
		</div></div>
	{{/?}}
	{{@:js_config}}{{:js_config}}
		{{?widget.ui_frontjs}}
			<a href="{{!static type='js' widget.ui_frontjs}}" id="frontjs{{widget.widget_id}}" class="dn"></a>
		{{/?}}
		{{?widget.ui_configurable && community.acl.community_edit.is_allowed}}
			<a href="{{!static type='js' widget.ui_settingsjs}}" id="setjs{{widget.widget_id}}" class="dn"></a>
		{{/?}}
	{{/:js_config}}
	
	{{@:widget_title}}{{:widget_title}}{{?widget.title}}<h3 class="title-">{{widget.title}}</h3>{{/?}}{{/:widget_title}}
	
	{{@:widget_body}}{{:widget_body}}{{/:widget_body}}
</div></div></div>


<!-- дефолтный блок настроек -->

{{:settings}}
	<!-- эта штука просто меняет порядок вызова основного шаблона формы настроек -->
	{{@:settings_layout settings_body=@:settings_body}}
{{/:settings}}

{{:settings_layout}}
	{{!connect compile="css"}}
	{{!connect compile="js"}}
	{{settings_body}}
{{/:settings_layout}}

{{:settings_body}}
	<div class="popup-body" id="settings_container">
		<div class="bg1-"><div class="bg3-"></div><div class="bg2-"></div></div>
	    <div class="bg4-"><div class="bg5-"></div><div class="bg6-"></div></div>
		<form action="" id="settingsform">
			<input type="hidden" name="widget_id" value="{{settings.id}}" id="widget_id" />
			<h4 class="title-">Настройка виджета</h4>
			<div class="fields- form-common"><div class="bgg1-"><div class="bgg2-"><div class="bgg3-">
			{{!for settings.form.fields as='field' do=@:formfield}}
			</div></div></div></div>
			{{@:settingsbutton}}{{:settingsbutton}}
				<ul class="buttons-">
					<li class="accept-"><a href="#">Сохранить</a></li>
					<li class="neutral-"><a href="#">Отмена</a></li>
				</ul>
			{{/:settingsbutton}}
		</form>
	</div>
{{/:settings_body}}



<!-- Эти шаблоны используются для генерации форм в настройках виджета -->

<!-- text -->

{{:formfield field.type == 'text'}}
	<fieldset class="fieldset- text-">
		<label class="label-">{{field.title}}</label>
		<input type="text" class="field-" id="fpl_{{field.name}}" name="{{field.name}}" value="{{field.value|escape}}"/>
		{{?field.description}}<div class="comment-">{{field.description}}</div>{{/?}}
	</fieldset>
{{/:formfield}}


<!-- textarea -->

{{:formfield field.type == 'textarea'}}
	<fieldset class="fieldset- textarea-">
		<label for="fpl_{{field.name}}" class="label-">{{field.title}}</label>
		<textarea id="fpl_{{field.name}}" name="{{field.name}}">{{field.value|escape}}</textarea>
		<div class="comment-">{{field.description}}</div>
	</fieldset>
{{/:formfield}}

<!-- wisiwig -->

{{:formfield field.type == 'wysiwig'}}
	<fieldset class="fieldset- wysiwyg-">
		<label for="fpl_{{field.name}}" class="label-">{{field.title}}</label>
		<textarea id="fpl_{{field.name}}" name="{{field.name}}" cols="60" rows="10" class="mceEditor full">{{field.value|escape}}</textarea>
		<div class="comment-">{{field.description}}</div>
		<script type="text/javascript">
			setTimeout("tinyMCE.execCommand('mceAddControl', false, 'fpl_{{field.name}}')",1);
		</script>
	</fieldset>
{{/:formfield}}


<!-- checklist -->

{{:formfield field.type == 'checklist'}}
	<fieldset class="fieldset- checkboxes- js_sectionslist">
		<label for="fpl_directory00" class="label-"><span class="root-"><input class="js_all_cb" type="checkbox" value="*" name="tdis[]" id="fpl_directory00"/><span class="all-">Выделить всё</span></span> Разделы</label>
		<ul class="list-">
			{{!for field.fields as='item' do=@:item_checkbox}}{{:item_checkbox}}
			<li><input class="js_cb" id="fpl_{{field.name}}{{For.key}}" type="checkbox" {{?item.checked}}checked="checked"{{/?}} name="{{field.name}}[]" value="{{item.value|escape}}"/><label for="fpl_{{field.name}}{{For.key}}">{{item.title}}</label></li>
			{{/:item_checkbox}}
		</ul>
		{{?field.description}}<div class="comment-">{{field.description}}</div>{{/?}}
	</fieldset>
{{/:formfield}}


<!-- select -->

{{:formfield field.type == 'select'}}
	<fieldset class="fieldset- select-">
		<label for="fpl_{{field.name}}" class="label-">{{field.title}}</label>
		<select id="fpl_{{field.name}}" name="{{field.name}}" class="field-">
			{{!for field.fields as='option' do=@:option}}{{:option}}
			<option value="{{option.value}}" {{?option.selected}}selected="selected"{{/?}}>{{option.title}}</option>
			{{/:option}}
		</select>
		{{?field.description}}<div class="comment-">{{field.description}}</div>{{/?}}
	</fieldset>
{{/:formfield}}
